package com.pswv2.withdraw.action;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pswv2.util.BackendErrorCode;
import com.pswv2.util.CommonResp;
import com.pswv2.withdraw.service.WithdrawService;



@Controller
@RequestMapping(value = "withdrawAction", produces = { "text/json;charset=UTF-8" })
public class WithdrawAction {
	@Autowired
	private WithdrawService withdrawService;
	@ResponseBody
	@RequestMapping("add")
	public String add(double money,Integer userId,String alipayName,String alipayAccount) {
		withdrawService.add(money, userId, alipayName, alipayAccount);
		return CommonResp.buildSuccessResp().toJsonString();
	}
	
	@ResponseBody
	@RequestMapping("alipayWithdraw")
	public String alipayWithdraw(double money,Integer userId,String alipayAccount) {
		Integer s=withdrawService.alipayWithdraw(money, userId, alipayAccount);
		System.out.println(s+"ssd");
		if(s==1){
			return CommonResp.buildSuccessResp().toJsonString();
		}else{
			return CommonResp.buildErrorResp(BackendErrorCode.alipay_fail).toJsonString();
		}
	}
}
